Skip to content

Commit

Permalink
Merge branch 'main' into fix/issue11893
Browse files Browse the repository at this point in the history
  • Loading branch information
mcanouil authored Jan 20, 2025
2 parents 4b81322 + a1badd7 commit e0bb444
Show file tree
Hide file tree
Showing 6 changed files with 1,066 additions and 1,015 deletions.
35 changes: 35 additions & 0 deletions dev-docs/performance-monitoring/linux-performance.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Notes for monitoring performance on Linux

Context: I've been having trouble getting consistent performance measurements on my MacBook Pro, so I decided to try my luck on an Intel Linux desktop running Ubuntu 24.

## `perf` settings

We'll want to monitor some performance counters that have potential security implications, so we need to disable some settings. ONLY DO THIS ON A MACHINE YOU TRUST AND THAT WILL NOT RUN POTENTIALLY-MALICIOUS THIRD-PARTY CODE!

### Source `scripts/linux-perf-settings.sh`

(These come from <https://easyperf.net/blog/2019/08/02/Perf-measurement-environment-on-Linux>)

### `sysctl.conf` settings

```
$ cat /proc/sys/kernel/perf_event_paranoid
```

If the result isn't `-1`, then add this to `/etc/sysctl.conf`:

```
kernel.perf_event_paranoid = -1
```

```
$ cat /proc/sys/kernel/kptr_restrict
```

If the result isn't `0`, then add this to `/etc/sysctl.conf`:

```
kernel.kptr_restrict = 0
```

After these changes, you'll need to reboot.
16 changes: 16 additions & 0 deletions dev-docs/performance-monitoring/scripts/linux-perf-settings.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash

# This assumes intel processors!!

# Intel
echo 1 > /sys/devices/system/cpu/intel_pstate/no_turbo
# AMD
# echo 0 > /sys/devices/system/cpu/cpufreq/boost

for i in /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor
do
echo performance > $i
done

echo 0 > /proc/sys/kernel/randomize_va_space

19 changes: 12 additions & 7 deletions src/command/render/pandoc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ import {
import { kFieldCategories } from "../../project/types/website/listing/website-listing-shared.ts";
import { isWindows } from "../../deno_ral/platform.ts";
import { appendToCombinedLuaProfile } from "../../core/performance/perfetto-utils.ts";
import { makeTimedFunctionAsync } from "../../core/performance/function-times.ts";

// in case we are running multiple pandoc processes
// we need to make sure we capture all of the trace files
Expand Down Expand Up @@ -1233,14 +1234,18 @@ export async function runPandoc(

setupPandocEnv();

const pandocRender = makeTimedFunctionAsync("pandoc-render", async () => {
return await execProcess(
{
cmd,
cwd,
env: pandocEnv,
},
);
});

// run pandoc
const result = await execProcess(
{
cmd,
cwd,
env: pandocEnv,
},
);
const result = await pandocRender();

// run afterPandoc hooks
for (const hook of afterPandocHooks) {
Expand Down
6 changes: 3 additions & 3 deletions src/resources/filters/ast/customnodes.lua
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ function is_regular_node(node, name)
return node
end

function run_emulated_filter(doc, filter, traverse)
function run_emulated_filter(doc, filter, traverser)
if doc == nil then
return nil
end
Expand Down Expand Up @@ -82,10 +82,10 @@ function run_emulated_filter(doc, filter, traverse)
elseif type(traverser) == 'function' then
_quarto.traverser = traverser
else
warn('Unknown traverse method: ' .. tostring(traverse))
warn('Unknown traverse method: ' .. tostring(traverser))
end
local result = _quarto.traverser(node, filter_param)
_quarto.traverse = old_traverse
_quarto.traverser = old_traverse

return result
end
Expand Down
13 changes: 3 additions & 10 deletions src/resources/filters/normalize/astpipeline.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,15 @@

function quarto_ast_pipeline()
local function warn_on_stray_triple_colons()
local function block_handler(block)
_quarto.ast.walk(block, {
Str = function(el)
return {
Str = function(el)
if string.match(el.text, ":::(:*)") then
local error_message =
"\nThe following string was found in the document: " .. el.text ..
"\nThis string was found in a block element with the following content:\n\n" .. pandoc.utils.stringify(block) ..
"\n\nThis usually indicates a problem with a fenced div in the document. Please check the document for errors."
warn(error_message)
end
end
})
end
return {
Para = block_handler,
Plain = block_handler,
end
}
end
return {
Expand Down
Loading

0 comments on commit e0bb444

Please sign in to comment.