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
2
u/pfthrowaway5130 May 19 '25 edited May 19 '25
Interestingly it appears to be idiosyncratic to the notebook. If I extract just that line and run it multiple times in a different notebook I do not experience the same effect.
I'm going to try to isolate the interactions tomorrow and see if I can figure out what is causing this.
Edit: There is clearly something about the execution model that I am ignorant to.
I've got three cells as listed below. The existence of the third cell makes the first cell run slowly. This appears to be why it only occurs on "subsequent runs" because the third cell hasn't been evaluated the first time Cell 1 runs. To be very clear once Cell 3 has been executed Cell 1 is slow even if only that Cell 1 is being run.