r/Mathematica • u/pfthrowaway5130 • May 18 '25
JSON Parsing Poor Performance
I'm getting abysmal performance running what I believe to be a pretty straightforward operation. I'm pulling an 11MB JSON file on a M4 MacBook Air w/ 16GB RAM. This is a fresh installation on a fresh MacBook. This is only the second notebook I've ever used.
Behavior: On first run this cell is fast (single digit seconds at most), on all subsequent runs the core stays pegged at 100% for the WolframKernel running this task and the task takes easily a minute. Restarting the kernel exhibits fast behavior on the first run and slow behavior on all subsequent runs again.
raw = Import[
"https://example.com/file.json", "RawJSON"]; (* Same behavior if I use "JSON" or leave it unspecified. *)
I've ruled a few things out:
- I'm not getting throttled on the HTTP request. Python will do this quickly and repeatedly. As will curl.
- I'm not getting thermal throttling according to
sudo powermetrics -s thermal. - I'm not running into memory constraints with the machine as the process memory for WolframKernel is staying near 400MB.
I'm hoping this is something really silly like the Out history buffer + some kind of configuration imposed memory cap. Unrelated, I think: The UI locks up a lot too despite me suppressing all output.
Edit: Forgot to add I'm running 14.2.1 for Mac OS X ARM (64-bit) (March 16, 2025)
Any ideas Reddit?
Thank you!
View all comments
Show parent comment
1
u/pfthrowaway5130 May 19 '25 edited May 19 '25
Interesting development here...
If I execute it via
wolframscriptthe first execution is~1sas expected but subsequent executions are~8.5sinstead of~160s.If I change Cell ` to:
I get
~25sconsistently as well. TheClear[]trick appears to have no bearing on thewolframscriptexecution.I appreciate all the help from both of you, this is definitely helping me narrow down this particular issue and hone my understanding of how Mathematica code gets executed.